package model;

import java.util.Arrays;

/**
 * Created by qianyu.zm on 2017/3/7.
 */
public class Board {

    public int[] table;
    public int longerSide, shorterSide;

    public Board(){}

    public Board(int width, int height){
        shorterSide = Math.min(width, height);
        longerSide = Math.max(width, height);
        table = new int[longerSide];
    }

    public void setLine(int index, String line){
        if(line.length() > shorterSide){
            throw new IllegalArgumentException(
                    "input line text is not right,its length must smaller than shorterSide:" + shorterSide);
        }
        table[index] = Integer.parseInt(line, 2);
    }

    public Board clone(){
        Board board = new Board();
        board.longerSide = this.longerSide;
        board.shorterSide = this.shorterSide;
        board.table = Arrays.copyOf(table, table.length);
        return board;
    }
}
